import type { DiscordEmoji } from '@discordeno/types'
import type { Bot } from '../../bot.js'
import type { Emoji } from '../types.js'

export function transformEmojiToDiscordEmoji(bot: Bot, payload: Emoji): DiscordEmoji {
  return {
    id: payload.id ? bot.transformers.reverse.snowflake(payload.id) : null,
    name: payload.name ?? null,
    roles: payload.roles?.map((id) => bot.transformers.reverse.snowflake(id)),
    user: payload.user ? bot.transformers.reverse.user(bot, payload.user) : undefined,
    require_colons: payload.toggles.requireColons,
    managed: payload.toggles.managed,
    animated: payload.toggles.animated,
    available: payload.toggles.available,
  }
}
